﻿module DomTypesImpl

open Might.Infrastructure.DOM
open Might.Infrastructure.ModelicaDOM
open Might.Infrastructure.ModelicaDOM.Modifications
open Might.Infrastructure.ModelicaDOM.Expressions
open Might.Infrastructure.ModelicaDOM.Equations
open Microsoft.FSharp.Text.Lexing

type ReferenceStatus =
    | Unresolved = 0
    | Resolving = 1
    | Set = 2
    | Invalid = 3

type ModelicaComponent() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _name: string
    [<DefaultValue>]
    val mutable private _visibility: Visibility
      
    [<DefaultValue>]
    val mutable refStatus:ReferenceStatus
    
    [<DefaultValue>]
    val mutable typeName:string
            
    interface IComponent with    
        member this.ComponentName
            with get() = this._name
            and set(v) = this._name <- v
            
        member this.ComponentVisibility
            with get() = this._visibility
            and set(v) = this._visibility <- v
                
end
and ModelicaClass() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _name: string    
    [<DefaultValue>]
    val mutable private _qualifiedName: string
    [<DefaultValue>]
    val mutable private _restrictedType: ModelicaClassType 
    [<DefaultValue>]  
    val mutable _encapsulated:bool

    [<DefaultValue>]  
    val mutable _startPosition: Position
    
    [<DefaultValue>]  
    val mutable _endPosition: Position
         
    interface IModelicaClass with
        
        member this.ClassName 
            with get() = this._name
            and set(v ) = this._name <- v
        member this.QualifiedClassName 
            with get() = this._qualifiedName
            and set(v ) = this._qualifiedName <- v
        member this.RestrictedType
            with get() = this._restrictedType
            and set(v) = this._restrictedType <- v
        member this.Encapsulated
            with get() = this._encapsulated
            and set(v) = this._encapsulated <- v
                             
end
and InheritanceDeclaration() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _isFromShortClassDef: bool
    [<DefaultValue>]
    val mutable private _visibility: Visibility
       
    [<DefaultValue>]
    val mutable refStatus:ReferenceStatus
        
    [<DefaultValue>]
    val mutable baseClassName:string    
        
    interface IInheritanceDeclaration with
        member this.IsFromShortClassDef
            with get() = this._isFromShortClassDef
            and set(v) = this._isFromShortClassDef <- v
        member this.Visibility
            with get() = this._visibility
            and set(v) = this._visibility <- v
        
    
end
and ImportDeclaration() = class
    inherit DomNode()

    [<DefaultValue>]
    val mutable private _importedName: string
    [<DefaultValue>]
    val mutable private _alias: string   

    [<DefaultValue>]
    val mutable refStatus:ReferenceStatus

    interface IImportDeclaration with
        member this.ImportedName
            with get() = this._importedName
            and set(v) = this._importedName <- v
        member this.Alias 
            with get() = this._alias
            and set(v) = this._alias <- v

end

and ClassModification() = class
    inherit DomNode()
    interface IClassModification
end
and ClassRedefinition() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _isEach: bool
    [<DefaultValue>]
    val mutable private _isFinal: bool
    [<DefaultValue>]
    val mutable private _isRedeclare: bool
    [<DefaultValue>]
    val mutable private _isReplaceable: bool
    
    interface IClassRedefinition with
        member this.IsEach 
            with get() = this._isEach
            and set(v) = this._isEach <- v
        member this.IsFinal 
            with get() = this._isFinal
            and set(v) = this._isFinal <- v
        member this.IsRedeclare 
            with get() = this._isRedeclare
            and set(v) = this._isRedeclare <- v
        member this.IsReplaceable 
            with get() = this._isReplaceable
            and set(v) = this._isReplaceable <- v
end
and ComponentRedefinition() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _isEach: bool
    [<DefaultValue>]
    val mutable private _isFinal: bool
    [<DefaultValue>]
    val mutable private _isRedeclare: bool
    [<DefaultValue>]
    val mutable private _isReplaceable: bool
        
    interface IComponentRedefinition with
        member this.IsEach 
            with get() = this._isEach
            and set(v) = this._isEach <- v
        member this.IsFinal 
            with get() = this._isFinal
            and set(v) = this._isFinal <- v
        member this.IsRedeclare 
            with get() = this._isRedeclare
            and set(v) = this._isRedeclare <- v
        member this.IsReplaceable 
            with get() = this._isReplaceable
            and set(v) = this._isReplaceable <- v
end
and ComponentModification() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _isEach: bool    
    [<DefaultValue>]
    val mutable private _isFinal: bool
    [<DefaultValue>]
    val mutable private _comment: string
    [<DefaultValue>]
    val mutable private _componentRef: ComponentReference
    
    interface IComponentModification with
        member this.IsEach 
            with get() = this._isEach
            and set(v) = this._isEach <- v
        member this.IsFinal
            with get() = this._isFinal
            and set(v) = this._isFinal <- v
        member this.Comment
            with get() = this._comment
            and set(v) = this._comment <- v
        member this.ComponentRef
            with get() = this._componentRef
            and set(v) = this._componentRef <- v

end

type ConnectClause() = class
    inherit DomNode()   
    
    [<DefaultValue>]
    val mutable leftRefStatus:ReferenceStatus
    
    [<DefaultValue>]
    val mutable rightRefStatus:ReferenceStatus
    
    
    [<DefaultValue>]
    val mutable private _leftCompReference : ComponentReference
    [<DefaultValue>]
    val mutable private _rightCompReference : ComponentReference
   
    interface IConnectClause with
        member this.RightCompReference
            with get() = this._rightCompReference
            and set(v) = this._rightCompReference <- v
        
        member this.LeftCompReference
            with get() = this._rightCompReference
            and set(v) = this._rightCompReference <- v       
            
end
    
type FncCallEquation() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _fncName : string
    [<DefaultValue>]
    val mutable private _fncArgs : FunctionArgs
    
    interface IFncCallEquation with
    
        member this.FncName
            with get() = this._fncName
            and set(v) = this._fncName <- v
        
        member this.FncArgs
            with get() = this._fncArgs
            and set(v) = this._fncArgs <- v
    
end 
    
type ForEquation() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _indices : ForIndices   
    
    interface IForEquation with
    
        member this.Indices
            with get() = this._indices
            and set(v) = this._indices <- v                    
end              
     
type ElseIfEquation() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _condition : Expression   
    
    interface IElseIfEquation with
    
        member this.Condition
            with get() = this._condition
            and set(v) = this._condition <- v                                         
end      

type IfEquation() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _condition : Expression   
    
    interface IIfEquation with
    
        member this.Condition
            with get() = this._condition
            and set(v) = this._condition <- v                                         
end   
      
type ElseWhenEquation() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _condition : Expression   
    
    interface IElseWhenEquation with
    
        member this.Condition
            with get() = this._condition
            and set(v) = this._condition <- v                                         
end         
      
type WhenEquation() = class
    inherit DomNode()
    
    [<DefaultValue>]
    val mutable private _condition : Expression   
    
    interface IWhenEquation with
    
        member this.Condition
            with get() = this._condition
            and set(v) = this._condition <- v                                         
end  

type SimpleEquation() = class
    inherit DomNode()

    [<DefaultValue>]
    val mutable private _leftExpression : SimpleExpression   
    
    [<DefaultValue>]
    val mutable private _rightExpression : Expression   
    
    interface ISimpleEquation with
    
        member this.LeftExpression
            with get() = this._leftExpression
            and set(v) = this._leftExpression <- v                                         
        member this.RightExpression
            with get() = this._rightExpression
            and set(v) = this._rightExpression <- v
end 
    